# !/usr/bin/env python
# coding=utf-8
# @Time    : 2017/12/20 16:08
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/wx_server_prototype.git
# @File    : upload_ui.py
# @Software: PyCharm
# @Version: 3.5.4
import unittest
from app import create_app
from app.service import token_service
from configs import current_config
from utils import my_request, my_file
import json


class UploadCase(unittest.TestCase):
	def setUp(self):
		self.app = create_app('testing')
		self.app_context = self.app.app_context()
		self.app_context.push()

	def tearDown(self):
		self.app_context.pop()

	def test_upload(self):
		"""

		:return: {
			Errcode int
			Errmsg  string
			}
		"""
		token = token_service.get_server_access_token2(True)
		assert token
		url = current_config.UPLOAD_UI_URL % (token)
		data_dict = my_file.load_json_file('../resource/menu.json')
		content = my_request.my_request5('POST', url, data_dict)
		print(content)
		# if ret_dict['errcode'] != 0:
		# 	print ret_dict['errmsg']
		# 	raise exceptions.BaseException
		# print 'finish upload'